package com.xfan.core.web;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import com.xfan.core.util.StringUtil;

/**
 * 实现增删改查的action 
 */
@SuppressWarnings("unchecked")
public class MapAction<T extends MapDao,K>  extends BaseAction<T>{
	private static final long serialVersionUID = -4845668989537700532L;
	private Map data;
	private List listData=new ArrayList();
	private String id;
	
	public String index(){
		return SUCCESS;
	}
	
	public String list(){
		listData=dao.getList(data);
		return SUCCESS;
	}
	
	public String show(){
		if(!StringUtil.isEmpty(id))data=dao.getById(id);
		return SUCCESS;
	}
	
	public String edit(){
		if(data.get("id")!=null){
			dao.update(data);
		}else{
			dao.insert(data);
		}
		return SUCCESS;
	}
	
	public String remove(){
		dao.remove(data);
		return SUCCESS;
	}

	public Map getData() {
		return data;
	}

	public void setData(Map data) {
		this.data = data;
	}

	public List getListData() {
		return listData;
	}

	public void setListData(List listData) {
		this.listData = listData;
	}
}
